import { Button } from 'antd-mobile'
import React from 'react'
import { useSelector } from 'react-redux'
import { useNavigate } from 'react-router-dom'

function My() {
    const navigate=useNavigate();
    //退出登录
    const toLogin=()=>{
        localStorage.removeItem('token')
        navigate('/login')
    }
    //回显我的页面信息 头像昵称
    const userInfo=useSelector(state=>state.user.userInfo)
  return (
    <div>
      <img src={userInfo.avatar} alt="" style={{width:"30vw", height:"20vh"}}/>
      <h1>{userInfo.nickname}</h1>
      <div>
        <Button style={{marginTop:"20px"}} onClick={toLogin} color='primary' fill='solid'>退出登录</Button>
      </div>
    </div>
  )
}

export default My
